package gov.nasa.anml.utility;


// mutable integers
// but using these as keys in a hashtable requires not changing the value
// i.e., be careful!
public class SimpleCharacter implements SimpleObject<SimpleCharacter> {

	public char v;

	public SimpleCharacter() {
		v = 0;
	}

	public SimpleCharacter(char v) {
		this.v = v;
	}

	public int hashCode() {
		return v;
	}

	public boolean equals(SimpleCharacter obj) {
		if (v == obj.v)
			return true;
		return false;
	}
	public boolean equals(Object obj) {
		if (obj instanceof SimpleCharacter && 
				v == ((SimpleCharacter)obj).v)
			return true;
		return false;
	}

	public SimpleCharacter clone() {
		try {
			return (SimpleCharacter) super.clone();
		} catch (CloneNotSupportedException e) {
			// assert false;
		}
		return null;
	}

	public int compareTo(SimpleCharacter o) {
		if (this == null || o == null)
			return 1;
		return v - o.v;
	}
	
	public int compareTo(SimpleObject<SimpleCharacter> o) {
		SimpleCharacter c = (SimpleCharacter) o;
		if (this == null || c == null)
			return 1;
		return v - c.v;
	}

	public String toString() {
		return java.lang.Character.toString(v);
	}

	public void assign(SimpleCharacter c) {
		v = c.v;
	}
	
	public void assign(char v) {
		this.v = v;
	}

	public SimpleCharacter value() {
		return this;
	}
}
